<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<form action="">
    账户名：<input type="text" name="devCode">
    密码：<input type="text" name="devPassword">
    <input type="button" id="denlu" value="登录">
</form>
</body>
<script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript">
    $("#denlu").click(function () {
        DenLu();
    })
    function DenLu (){
        var devCode = $("input[name='devCode']").val();
        var devPassword = $("input[name='devPassword']").val();
        $.ajax({
            "url":"/XiangMu_war_exploded/login",
            "type":"post",
            "data":{"devCode":devCode,"devPassword":devPassword},
            "dataType":"json",
            "success":function(r){
                var result = JSON.parse(r);
                if(result==0){
                    alert("登录成功");
                    window.location.href="/XiangMu_war_exploded/toselAp";
                }else if(result==1){
                    alert("登录成功");
                    window.location.href="/XiangMu_war_exploded/toshenheAp";
                }else{
                    alert("登录失败");
                    window.location.href="/XiangMu_war_exploded/tologin";
                }
            },
            "error":function(){
                alert("服务器错误");
            }
        });
    }
</script>
</html>
